// Code that creates complier profiling plots
// Figure A8.
// Last changed: 2020-04-02 (KOL)
//
//		
  	

  capture log close
  local output "C:\Userdata\Shared\Dofiles\DoAnalysis\PlacementCandidacy\Output"
  cd `output'
  
  log using "FigureA8.log", replace text
  
  use "E:\ProjData\PlacementCandidacy\utp-DataMainSample.dta", clear

  ivdesc InvAr Enklav EnklavInvAr, reps(1000)
  matrix C = r(ivdesc)'
  coefplot matrix(C), se(C[2]) levels(95) fxsize(100) name(g1, replace) xscale(range(1988.8 1989.2)) xlabel(1988.8 1989.0 1989.2) msize(small) ///
                      graphregion(color(white))  ylabel(1 "Sample" 2 "Compliers" 3 "Never-takers" 4 "Always-takers") title("Year of Immigration", size(medium))
  
  ivdesc InvAlder Enklav EnklavInvAr, reps(1000) 
  matrix C = r(ivdesc)'
  coefplot matrix(C), se(C[2]) levels(95) fxsize(75) ylabel(, nolabels) name(g2, replace)  xscale(range(28 32)) xlabel(28 30 32) ///
  graphregion(color(white)) title("Age at Immigration", size(medium)) msize(small)

  ivdesc TidISverige Enklav EnklavInvAr, reps(1000) 
  matrix C = r(ivdesc)'
  coefplot matrix(C), se(C[2]) levels(95) fxsize(75) ylabel(, nolabels) name(g3, replace)  xscale(range(11 18)) xlabel(11 15 18) ///
  graphregion(color(white)) title("Years in Country", size(medium)) msize(small)

  ivdesc AlderValDag Enklav EnklavInvAr, reps(1000) 
  matrix C = r(ivdesc)'
  coefplot matrix(C), se(C[2]) levels(95) fxsize(75)  xscale(range(42 48)) xlabel(42 45 48) name(g4, replace) msize(small) ///
  graphregion(color(white)) title("Age at Election", size(medium)) ylabel(1 "Sample" 2 "Compliers" 3 "Never-takers" 4 "Always-takers")

  ivdesc UtbAr_InvAr Enklav EnklavInvAr, reps(1000) 
  matrix C = r(ivdesc)'
  coefplot matrix(C), se(C[2]) levels(95) fxsize(100) name(g5, replace)  xscale(range(10 11.5)) xlabel(10(.5)11.5) ///
                      graphregion(color(white))  ylabel(1 "Sample" 2 "Compliers" 3 "Never-takers" 4 "Always-takers") msize(small) title("Years of Education", size(medium))
  
  ivdesc Gift_InvAr Enklav EnklavInvAr, reps(1000) 
  matrix C = r(ivdesc)'
  coefplot matrix(C), se(C[2]) levels(95) fxsize(75) ylabel(, nolabels) name(g6, replace)  xscale(range(.54 .62)) xlabel(.54 .58 .62) ///
  graphregion(color(white)) msize(small) title("Married", size(medium))

  ivdesc Barn0_15_InvAr Enklav EnklavInvAr, reps(1000) 
  matrix C = r(ivdesc)'
  coefplot matrix(C), se(C[2]) levels(95) fxsize(75) name(g7, replace)  xscale(range(.9 1.2)) xlabel(.8 1.0 1.2) ///
  graphregion(color(white)) ylabel(1 "Sample" 2 "Compliers" 3 "Never-takers" 4 "Always-takers") msize(small) title("Children", size(medium))
  
  ivdesc Kvinna Enklav EnklavInvAr, reps(1000) 
  matrix C = r(ivdesc)'
  coefplot matrix(C), se(C[2]) levels(95) fxsize(75) name(g8, replace)  xscale(range(.3 .6)) xlabel(.25 .4 .55) ///
  graphregion(color(white)) ylabel(, nolabels) msize(small) title("Female", size(medium))
  
  gen aStorlek_Kom_InvAr = Storlek_Kom_InvAr/1000
  
  ivdesc aStorlek_Kom_InvAr Enklav EnklavInvAr, reps(1000) 
  matrix C = r(ivdesc)'
  coefplot matrix(C), se(C[2]) levels(95) fxsize(75) name(g9, replace) title("Municipality Size", size(medium))  ///
  graphregion(color(white)) ylabel(, nolabels)  xscale(range(50 250)) xlabel(50 150 250) msize(small)
  
  graph combine g1 g2 g9 g7 g6 g8 g5, graphregion(color(white)) col(3)
  graph export "`output'\FigureA8.png", replace
  
  log close
